﻿<div [@routerTransition] (window:resize)="onResize($event)">
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title">
                    <span>审批权限管理</span>
                </h3>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <tabset class="tab-container tabbable-line">
                    <tab heading="车间审批领导" customClass="m-tabs__item">
                            <form class="horizontal-form" autocomplete="off">
                                <div class="m-form m-form--label-align-right">
                                    <div class="row align-items-center m--margin-bottom-10">
                                        <div class="col-xl-12">
                                            <div class="form-group m-form__group align-items-center">
                                                <div class="input-group">
                                                    <input [(ngModel)]="filterText" name="filterText" autoFocus class="form-control m-input" [placeholder]="l('SearchWithThreeDot')" type="text">
                                                    <span class="input-group-btn">
                                                        <button (click)="getRequirementPackages()" class="btn btn-primary" type="submit"><i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i></button>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        <div class="row margin-bottom-10">
                            <div class="col-xl-6">
                                <p>审核权限列表</p>
                            </div>
                            <div class="col-xl-6 text-right">
                                <button class="btn btn-primary" (click)="createOrEditRequirementPackage()"><i class="fa fa-edit"></i>新增</button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="primeng-datatable-container"
                                    [busyIf]="primengTableHelper.isLoading">
                                <p-table #dataTable
                                            (onLazyLoad)="getRequirementPackages($event)"
                                            [value]="primengTableHelper.records"
                                            rows="{{primengTableHelper.defaultRecordsCountPerPage}}"
                                            [paginator]="false"
                                            [lazy]="true"
                                            [scrollable]="true"
                                            ScrollWidth="100%"
                                            [responsive]="primengTableHelper.isResponsive"
                                            [resizableColumns]="primengTableHelper.resizableColumns">
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th style="width: 130px" [hidden]="!isGrantedAny('Pages.StandardPartsManager.AuditAuthority', 'Pages.StandardPartsManager.AuditAuthority.Edit', 'Pages.StandardPartsManager.AuditAuthority.Delete')">{{'Actions' | localize}}</th>
                                            <th style="width: 150px">
                                                序号
                                            </th>
                                            <th style="width: 300px" pSortableColumn="role">
                                                角色
                                                <p-sortIcon field="role"></p-sortIcon>
                                            </th>
                                            <th style="width: 300px">
                                                车间
                                            </th>
                                            <th style="width: 300px" pSortableColumn="userId">
                                                账号
                                                <p-sortIcon field="userId"></p-sortIcon>
                                            </th>
                                            <th style="width: 300px" pSortableColumn="userName">
                                                姓名
                                                <p-sortIcon field="userName"></p-sortIcon>
                                            </th>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-record="$implicit" let-rowIndex="rowIndex">
                                        <tr>
                                            <td style="width: 130px"
                                                [hidden]="!isGrantedAny('Pages.StandardPartsManager.AuditAuthority', 'Pages.StandardPartsManager.AuditAuthority.Edit', 'Pages.StandardPartsManager.AuditAuthority.Delete')">
                                                <div class="btn-group dropdown" dropdown container="body">
                                                    <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                        <i class="fa fa-cog"></i><span class="caret"></span> {{"Actions" | localize}}
                                                    </button>
                                                    <ul class="dropdown-menu" *dropdownMenu>
                                                        <!--<li *ngIf="('Pages.Administration.Users.Edit' | permission)  ">
                                                            <a href="javascript:;" (click)="createOrEditRequirementItem(record)">编 辑</a>
                                                        </li>-->
                                                        <li *ngIf="('Pages.StandardPartsManager.AuditAuthority' | permission) ">
                                                            <a href="javascript:;" (click)="deleteRequirementPackage(record)">删 除</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title">序号</span>
                                                {{rowIndex + 1}}
                                            </td>
                                            <td style="width: 300px">
                                                <span class="ui-column-title">角色</span>
                                                {{getRoleName(record.role)}}
                                            </td>
                                            <td style="width: 300px">
                                                <span class="ui-column-title">车间</span>
                                                {{getUnitOfUsingsName(record.unitOfUsing)}}
                                            </td>
                                            <td style="width: 300px">
                                                <span class="ui-column-title">账号</span>
                                                {{record.userId}}
                                            </td>
                                            <td style="width: 300px">
                                                <span class="ui-column-title">姓名</span>
                                                {{record.userName}}
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                                <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                    {{'NoData' | localize}}
                                </div>
                                <div class="primeng-paging-container">
                                    <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                                    #paginator
                                                    (onPageChange)="getRequirementPackages($event)"
                                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
        
                                    </p-paginator>
                                    <span class="total-records-count">
                                        {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                                    </span>
                                </div>
                            </div>
                        </div>
                    </tab>
                    <tab *ngFor="let tab of tabs"  [heading]="tab.name"  [active]="tab.active"  (deselect)="tab.active = false">
                        <auditAuthorityTabComponent #auditAuthorityTabComponent [index]="tab.index" ></auditAuthorityTabComponent>
                    </tab>
                </tabset>
            </div>
        </div>
    </div>
    <auditAuthorityEditComponent #auditAuthorityEditComponent (modalSave)="getRequirementPackages()"></auditAuthorityEditComponent>
</div>
